package com.tpu.daoclasses;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.hibernate.Session;

import com.tpu.bdclasses.Deliver;
import com.tpu.bdclasses.Distanse;
import com.tpu.bdclasses.Event;
import com.tpu.bdclasses.KindOfTicket;
import com.tpu.bdclasses.TheaterUser;
import com.tpu.bdclasses.TheatreOrder;
import com.tpu.bdclasses.Ticket;

public class EngineP {

	/**
	 * @param args
	 */
	public static void main(String[] args) 
	{
		BdDao bddao=new BdDao();
		Event ev=new Event(0,0,null,null,null,null,null);
		KindOfTicket kot=new KindOfTicket();
		kot.setKot_id(0);
		kot.setPrice(10);
		kot.setValueKindOfTicket("zal");
		Ticket tc=new Ticket(0, 1,1,kot,
		ev, null);
		kot.setTicket(tc);
		TheaterUser tuser= new TheaterUser("john","smith","smith@gmail.com",8913,"pass","smith",234);
		Deliver del=new Deliver();
		del.setDeliver_id(0);
		del.setName("jjj");
		Distanse dis=new Distanse();
		dis.setDistanse_id(0);
		dis.setName("jj");
		TheatreOrder order=new TheatreOrder(new Date(), new Date(),0,"hhh", tuser, del,dis, 0);
		order.addTicket(tc);
		dis.setToe(order);
		
		
		
		del.setTheorder(order);
		
		tuser.addOrders(order);
		TheaterUser tu= new TheaterUser("john","smith","smith@gmail.com",8913,"pass","smith",10);
		
		TheaterUser tu2= new TheaterUser("mary","cate","cate@gmail.com",8913,"pass2","cate",1);
		//bddao.startOperation();
		bddao.Save(tu2);
		bddao.Save(tu);
		//System.out.println(((TheaterUser)bddao.Find(TheaterUser.class,1 )).getName());
		
		TheaterUser rt=(TheaterUser)bddao.Getobject(TheaterUser.class,1);
		System.out.println(rt.getName());
		//bddao.endOperation();
		/*List tt=new ArrayList();
//		 tt=bddao.MySqlQuery("select * from client  where user_id=1");
		 Session ss=bddao.getSession();
		 tt=ss.createSQLQuery("select name,surname,email,tel,password,login from client  where user_id=1").list();
		 
		// TheaterUser tu3=new TheaterUser(tt.get(0).toString(),tt.get(1).toString(),tt.get(2).toString(),Integer.parseInt(tt.get(3).toString()),tt.get(4).toString(),tt.get(5).toString(),Integer.parseInt(tt.get(6).toString()));
		 //System.out.println(tu3.getName());
		 tt=ss.createSQLQuery("select * from client  where user_id=1").list();
		 System.out.println(tt.toString());
		 */
		

	}

}
